#include "uart.h"
#include <stdlib.h>
#include <string.h>
uint8_t *g_recv_mcu1_data;
#define MCU1_HUART huart1
extern UART_HandleTypeDef huart1;
void InitUartData(void)
{
  g_recv_mcu1_data = (uint8_t *)malloc(RECEIVE_LEN + 40);
  memset(g_recv_mcu1_data, 0, RECEIVE_LEN + 40);
  HAL_UARTEx_ReceiveToIdle_DMA(&huart1, g_recv_mcu1_data, RECEIVE_LEN + 40);
}

void EnableUart(void)
{
  HAL_UARTEx_ReceiveToIdle_DMA(&huart1, g_recv_mcu1_data, RECEIVE_LEN + 40);
}

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
  if (huart->Instance == USART1)
  {
    for (uint8_t i = 0; i < Size; i++)
    {
      if (g_recv_mcu1_data[i] == 'J' && g_recv_mcu1_data[i + 1] == 'T' &&
          g_recv_mcu1_data[i + 2] == 'S')
      {
      }
    }
  }
  HAL_UARTEx_ReceiveToIdle_DMA(&MCU1_HUART, g_recv_mcu1_data,
                               RECEIVE_LEN + 40);
}
